package com.boarsoft.boar.batch.biz;

import java.util.List;

import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.boarsoft.boar.batch.entity.BatchApp;
import com.boarsoft.common.Util;
import com.boarsoft.common.biz.SimpleBizImpl;

@Component
public class BatchAppBizImpl extends SimpleBizImpl implements BatchAppBiz {

	@Override
	@Transactional(readOnly = true)
	public BatchApp get(String addr) {
		return dao.get(BatchApp.class, addr);
	}

	@Override
	@Transactional
	public Object save(BatchApp o) {
		if (Util.strIsEmpty(o.getAddr())) {
			throw new RuntimeException("addr cannot be null");
		} else {
			return dao.merge(o);
		}
	}

	@Override
	@Transactional
	public void delete(String id) {
		dao.delete(BatchApp.class, id);
	}

	@Override
	public List<BatchApp> list() {
		return dao.list(BatchApp.class, " order by lockTime desc, addr asc");
	}
}
